package com.i2works.smartluolong.web.controller.index;

import com.i2works.smartluolong.utils.exception.ServiceException;
import com.i2works.smartluolong.web.entity.items.ItemsCategoryDO;
import com.i2works.smartluolong.web.entity.items.ItemsCategoryQuery;
import com.i2works.smartluolong.web.service.items.IItemsCategoryService;
import com.i2works.smartluolong.web.utils.BaseModule;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping({"/zwgk"})
public class ZwgkController extends BaseModule
{
  private final IItemsCategoryService itemsCategoryService;

  @Autowired
  public ZwgkController(IItemsCategoryService itemsCategoryService)
  {
    this.itemsCategoryService = itemsCategoryService;
  }

  @GetMapping({"", "/", "/index"})
  public String zwgk(Model model)
  {
    try
    {
      ItemsCategoryQuery cateQuery = new ItemsCategoryQuery();
      cateQuery.setStatus(Integer.valueOf(1));
      List cateList = this.itemsCategoryService.queryList(cateQuery);
      cateQuery.setId(Integer.valueOf(17));
      ItemsCategoryDO cate = (ItemsCategoryDO)this.itemsCategoryService.query(cateQuery);
      model.addAttribute("cateId", Integer.valueOf(17));
      model.addAttribute("cateTitle", cate.getTitle());
      model.addAttribute("cateList", cateList);
    } catch (ServiceException e) {
      e.printStackTrace();
    }
    return "/zwgk";
  }
}